package com.woniu.controller;


import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.woniu.entity.CreExamine;
import com.woniu.service.CreditExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;


import com.ruoyi.common.core.page.TableDataInfo;

import java.util.List;

/**
 * CreditExamineController
 *
 * @author 陈泓霖
 * @date 2022-09-26
 */
@RestController
@RequestMapping("/credit/examine")
public class CreditExamineController extends BaseController
{
    @Autowired
    private CreditExamineService creditExamineService;

    /**
     * 查询列表
     */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody CreExamine creExamine)
    {
        startPage();
        List<CreExamine> list = creditExamineService.selectCreExamineList(creExamine);
        return getDataTable(list);
    }

    /**
     * 查询列表
     */
    @PostMapping("/listByOrderId")
    public AjaxResult listByOrderId(@RequestBody CreExamine creExamine)
    {
        CreExamine creExamine2 = creditExamineService.selectCreExamineByOrderId(creExamine);
        return AjaxResult.success(creExamine2);
    }

    /**
     * 导出列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, CreExamine creExamine)
    {
        List<CreExamine> list = creditExamineService.selectCreExamineList(creExamine);
        ExcelUtil<CreExamine> util = new ExcelUtil<CreExamine>(CreExamine.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取详细信息
     */
    @GetMapping(value = "/{examineId}")
    public AjaxResult getInfo(@PathVariable("examineId") int examineId)
    {
        return AjaxResult.success(creditExamineService.selectCreExamineByExamineId(examineId));
    }

    /**
     * 新增
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody CreExamine creExamine)
    {
        System.out.println("进入add方法");
        System.out.println(creExamine);
        return toAjax(creditExamineService.insertCreExamine(creExamine));
    }

    /**
     * 修改
     */
    @PutMapping
    public AjaxResult edit(@RequestBody CreExamine creExamine)
    {
        return toAjax(creditExamineService.updateCreExamine(creExamine));
    }

    /**
     * 删除
     */
    @DeleteMapping("/{examineIds}")
    public AjaxResult remove(@PathVariable int[] examineIds)
    {
        return toAjax(creditExamineService.deleteCreExamineByExamineIds(examineIds));
    }
}